﻿@{
    ViewBag.Title = "登录页";
}

<style type="text/css">
    #loginPanel{

        width:400px;
        margin:100px auto;

    }
</style>

<div class="panel panel-default" id="loginPanel">
    <div class="panel-heading">登录</div>
    <div class="panel-body">

        <form>
            <div class="form-group">
                <label for="exampleInputEmail1">用户名:</label>
                <input type="email" class="form-control" id="txtUserName" placeholder="用户名">
            </div>
            <div class="form-group">
                <label for="exampleInputPassword1">密码:</label>
                <input type="password" class="form-control" id="txtbPassword" placeholder="Password">
            </div>
           
            <button type="button" class="btn btn-default" onclick="login();">登录</button>
        </form>
    </div>
</div>

<script type="text/javascript">


    function login() {

        //取用户 名
        var userName = $("#txtUserName").val();
        //取密码
        var password = $("#txtbPassword").val();
        //判断是否为空
        if (userName == '' || password == '') {
            alert("用户名和密码都必须要有哦!");
            return false;
        }

        //提交到远方去验证

        $.ajax({
            type: "POST",
            url: "/WebAPI/SysCommon/validateUser?userName="+userName+"&password="+password, success: function (result) {
              
                if (result.ID > 0) {
                    window.location.href = "/Home/Index";
                }else{
                    alert(result.Msg);
                }
               


            }
        });
    }

   



</script>
